﻿using habbo.Habbo.Catalog;
using habbo.Kernel.Packets.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace habbo.Kernel.Packets.com.sulake.habbo.communication.messages.outgoing.catalogue
{
    class CatalogPageMessageComposer : ServerPacket
    {
        public CatalogPageMessageComposer(int PageId)
            : base(2676)
        {
            CatalogPage Page = SystemApp.HabboSystem.CatalogManager.WeakAllPagesCache[PageId];
            if (Page != null)
            {
                base.Append(Page.Id);

                switch (Page.Layout)
                {
                    case "frontpage":
                        base.Append("frontpage3");

                        base.Append(3); //somecount
                        base.Append("catalog_frontpage_headline2_en");
                        base.Append("ts_mythbunnies_v1");
                        base.Append(string.Empty);
                        base.Append(11); //SomeCount LAWL
                        base.Append(string.Empty); //special
                        base.Append("We're updating the catalogue:)"); //page.Text1
                        base.Append(string.Empty);
                        base.Append(@"How to get Habboon CreditsThere are lots of ways to earn Habboon Credits, here are just a few ways;
Every 15 minutes gain 75 credits                             Unlock achievements for credits                               Verify your email for 2500 credits                                 Purchase VIP for double credits!");
                        base.Append("Redeem a voucher code here:");
                        base.Append(string.Empty);
                        base.Append("Rares");
                        base.Append("#FEFEFE");
                        base.Append("#FEFEFE");
                        base.Append("Click here for more information >>");
                        base.Append("magic.credits");
                        break;

                    case "spaces":
                        base.Append("spaces_new");
                        base.Append(1);
                        base.Append(Page.PageHeadline);
                        base.Append(1);
                        base.Append(Page.PageText1);
                        break;

                    case "trophies":
                        base.Append("trophies");
                        base.Append(1);
                        base.Append(Page.PageHeadline);
                        base.Append(2);
                        base.Append(Page.PageText1);
                        base.Append(Page.PageDetails);
                        base.Append(0);
                        base.Append(0);
                        base.Append(-1);
                        break;

                    case "pets":
                        base.Append("pets");
                        base.Append(2);
                        base.Append(Page.PageHeadline);
                        base.Append(Page.PageTeaser);
                        base.Append(4);
                        base.Append(Page.PageText1);
                        base.Append("Give a name:");
                        base.Append("Pick a color:");
                        base.Append("Pick a race:");
                        break;

                    case "guild_frontpage":
                        base.Append(Page.Layout);
                        base.Append(2);
                        base.Append("catalog_groups_en");
                        base.Append("");
                        base.Append(3);
                        base.Append(Page.PageTeaser);
                        base.Append(Page.PageSpecial);
                        base.Append(Page.PageText1);
                        break;

                    default:
                        base.Append(Page.Layout);
                        base.Append(3);
                        base.Append(Page.PageHeadline);
                        base.Append(Page.PageTeaser);
                        base.Append(Page.PageSpecial);
                        base.Append(3);
                        base.Append(Page.PageText1);
                        base.Append(Page.PageDetails);
                        base.Append(Page.PageTeaser2);
                        break;
                }
                if (!Page.Layout.Equals("frontpage") && !Page.Layout.Equals("club_buy"))
                {
                    base.Append(Page.Items.Count);
                    foreach (CatalogItem Item in Page.Items)
                    {
                        Item.Serialize(this, Page);
                    }
                }
                else
                    base.Append(0);

                base.Append(-1);
                base.Append(false);
            }
        }
    }
}
